package com.fbty.mt.action.admin;

import java.util.ArrayList;
import java.util.List;

import com.fbty.base.action.BaseAction;
import com.fbty.mt.domain.Price;
import com.fbty.mt.service.PriceService;
import com.fbty.mt.utils.StaticValue;

@SuppressWarnings("serial")
public class PriceManagerAction extends BaseAction {
	private PriceService priceService;
	
	private List<Price> generalPrices = new ArrayList<Price>();
	
	private List<Price> monthPrices = new ArrayList<Price>();
	
	private List<Price> onlyPrices = new ArrayList<Price>();
	
	
	private int num;
	
	private double price;
	
	private int type;
	
	private int useTime;
	
	private int id;
	public String showPrice(){
		List<Price> list = priceService.queryPrices();
		for(Price p:list){
			switch (p.getType()) {
			case StaticValue.GENERAL:
				generalPrices.add(p);
				break;
			case StaticValue.MONTH:
				monthPrices.add(p);
				break;
			case StaticValue.ONLY:
				onlyPrices.add(p);
				break;
			}
		}
		return "show";
	}

	public String add(){
		Price p = priceService.findPriceById(id);
		System.out.println(id);
		if(p==null){
			p=new Price();
			p.setNum(num);
			p.setPrice(price);
			p.setType(type);
			p.setUseTime(useTime);
			p.setSort(1);
		}else{
			p.setNum(num);
			p.setPrice(price);
			p.setUseTime(useTime);
		}
		priceService.savePrice(p);
		return "save";
	}
	
	
	
	
	public String del(){
		priceService.deletePrice(id);
		return "delete";
	}
	
	public void setPriceService(PriceService priceService) {
		this.priceService = priceService;
	}

	public List<Price> getGeneralPrices() {
		return generalPrices;
	}

	public void setGeneralPrices(List<Price> generalPrices) {
		this.generalPrices = generalPrices;
	}

	public List<Price> getMonthPrices() {
		return monthPrices;
	}

	public void setMonthPrices(List<Price> monthPrices) {
		this.monthPrices = monthPrices;
	}

	public List<Price> getOnlyPrices() {
		return onlyPrices;
	}

	public void setOnlyPrices(List<Price> onlyPrices) {
		this.onlyPrices = onlyPrices;
	}

	public int getNum() {
		return num;
	}

	public void setNum(int num) {
		this.num = num;
	}

	public double getPrice() {
		return price;
	}

	public void setPrice(double price) {
		this.price = price;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public int getUseTime() {
		return useTime;
	}

	public void setUseTime(int useTime) {
		this.useTime = useTime;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}
	
	
	
	
}
